package com.ywd.platform.controller;

import com.ywd.platform.exception.R;
import com.ywd.platform.netty.config.NettyServerLauncher;
import com.ywd.platform.netty.result.ServerStatus;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 管理端点（可选）
 */
@AllArgsConstructor
@RestController
@RequestMapping("/netty/server")
@Tag(name = "Netty服务管理")
public class NettyServerController {

    private final NettyServerLauncher serverLauncher;

    @GetMapping("/status")
    @Operation(summary = "Netty服务状态")
    public R<ServerStatus> getStatus() {
        return R.ok(serverLauncher.getServerStatus());
    }

//    @PostMapping("/restart")
//    @Operation(summary = "Netty服务重启")
//    public R<String> restart() {
//        try {
//            serverLauncher.shutdown();
//            // 这里可以添加重启逻辑
//            return R.ok("Netty服务成功");
//        } catch (Exception e) {
//            return R.ok("Netty服务重启失败");
//        }
//    }
}
